package ModelLayer;

public class Customer extends Person {
	
	private static final long serialVersionUID = 1L;
	private static int lastId = 0;
	private Group group;
	public Customer(String name, String address, long phone, int group) throws RealException {
		super(name, address, phone);
		setId(generateId()); 
		this.group = GroupRecords.getInstance().getGroup(group);
	}

	public Group getGroup() {
		return group;
	}

	public void setGroup(Group group) {
		this.group = group;
	}
	
	public void updateGroup(int id) throws RealException
	{
		setGroup(GroupRecords.getInstance().getGroup(id));		
	}
	
	public String toString()
	{
		return super.toString() + " Group id: " + getGroup().getId();
	}
	
	public int generateId()
	{
		return ++lastId;
	}
	
	public static int getLastId()
	{
		return lastId;
	}
	
	public static void setLastId(int lastid)
	{
		lastId = lastid;
	}
	

}
